package cn.anosi.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.anosi.entity.auth.ActiveUser;


@Controller
public class PageController extends BaseController{
	@RequestMapping(value={"/", "/index"}, method=RequestMethod.GET)
	public String index(Model model){
		// 从shiro的session中取activeUser
		Subject subject = SecurityUtils.getSubject();
		// 取身份信息
		ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
		model.addAttribute("activeUser", activeUser);
		return "index";
	}
	
	@RequestMapping(value="/404", method=RequestMethod.GET)
	public String pageNotFound(){
		return "404";
	}
	
	@RequestMapping(value="/500", method=RequestMethod.GET)
	public String serverError(){
		return "500";
	}
	
	@RequestMapping(value="/error", method=RequestMethod.GET)
	public String exception(){
		return "error";
	}
	
	@RequestMapping(value="/welcome", method=RequestMethod.GET)
	public String welcome(){
		return "welcome";
	}
	
	@RequestMapping("/tools/form_builder")
	public String formBuilder(){
		return "tools/form_builder";
	}
	
	@RequestMapping("/tools/Glyphicons")
	public String Glyphicons(){
		return "tools/Glyphicons";
	}
	
	@RequestMapping("tools/FontAwesome")
	public String fontAwesome(){
		return "tools/FontAwesome";
	}
}